package com.longtop.leaning.ui;

import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;
import javax.microedition.lcdui.CommandListener;

import com.longtop.leaning.data.FlightUIData;
import com.longtop.leaning.midlet.FlightMIDlet;


public class FlightMenu extends List implements CommandListener  {
	
	private FlightMIDlet _flightMIDlet = null;
	
	public FlightMenu (FlightMIDlet flightMIDlet){		
		super("选您的功能菜单", Choice.IMPLICIT, FlightUIData.MENU_DATA, null);
		_flightMIDlet = flightMIDlet;
		this.addCommand(FlightUIData.CMD_BACK);		
		this.setCommandListener (this);
	}

	public void commandAction(Command c, Displayable d) {
		System.out.println("sfsdf");
		if (d.equals (this)) {
            // in the main list
            if (c == List.SELECT_COMMAND) {
                if (d.equals (this)) {
                    switch (((List) d).getSelectedIndex ()) {
                    case 0:
                    	//TODO 这里执行下载数据操作
                        break;

                    case 1:
                    	_flightMIDlet.showFlightQueryForm();

                        break;
                    }
                }
            }		
        }
        else {
            // in one of the sub-lists
            if (c == FlightUIData.CMD_BACK) {
            	_flightMIDlet.showLoginForm();
            }
        }        
	}
}
